package de.tmahr.android;

import android.app.Activity;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;

public class FontTest extends Activity
{
	private RenderView view;

	class RenderView extends View
	{
		Paint paint;
		Typeface font;
		Rect bounds = new Rect();
		float y = 0;
		float vy = 1;
		float vFont = 0.4f;
		float fontSize = 0;

		public RenderView(Context c)
		{
			super(c);
			paint = new Paint();
			font = Typeface.createFromAsset(c.getAssets(), "font.ttf");
		}

		protected void onDraw(Canvas c)
		{
			paint.setColor(Color.YELLOW);
			paint.setTypeface(font);
			paint.setTextSize(fontSize);
			paint.setTextAlign(Paint.Align.CENTER);
			c.drawText("Ich liebe dieses Wahlpflichtfach!", c.getWidth() / 2, y, paint);

			fontSize += vFont;
			y += vy;
			if(y>c.getHeight())
			{
				y = 0;
				fontSize = 0;
			}
			
			invalidate();
		}
	}

	@Override
	public void onCreate(Bundle b)
	{
		super.onCreate(b);
		setTitle(FontTest.class.getSimpleName());
		view = new RenderView(this);
		setContentView(view);
	}
}
